#ifndef GTSORT_H
#define GTSORT_H

#include <errno.h>
#include <stddef.h>

#define ERROR_MEM_ALLOC -1

#if defined(_WIN32) && defined(_MSC_VER)
#define restrict __restrict
#endif

errno_t swap(
	void *restrict left, \
	void *restrict right, \
	size_t size, \
	void **context);

static inline void *address(
	void *base, \
	size_t num, \
	size_t size)
{
	return (void*)((size_t)base + num*size);
}

errno_t sort(
	void *base, \
	size_t num, \
	size_t size, \
	int(*comp)(const void*, const void*, void*), \
	void *ctx);

#endif